<?php
/**
 * Created by PhpStorm.
 * User: 76937
 * Date: 2016/9/28
 * Time: 19:56
 */header('Content-type:text/html;charset=utf-8');
?>
<!doctype html>
 <html>
<head>
    <meta charset="utf-8">
    <title>金字塔</title>
    <style>
        .bordered{border: solid 3px #000; float: left; overflow: hidden;}
        .box{background-color: #000000; margin:3px; padding: 2px; font-size: 20px;
            font-weight: bold; color: #ffffff;}
    </style>
</head>
<body>
 <div class="bordered">
    <div class="box">
    <?php
  $line=1;
  while($line<=5){
      $empty_pos=$star_pos=1;
      $empty=5-$line;
      $star=2*$line-1;
      while($empty_pos<=$empty){
          echo '&nbsp;';
          ++$empty_pos;
      }
      while ($star_pos<=$star){
          echo '*';
          ++$star_pos;
      }
      echo '<br>';
      ++$line;
  }
?>
</div>
</div>
</body>
</html>
